{extend name="layouts@base" /}
{block name="head"}
<link rel="stylesheet" href="__STATIC__/mobile/default/css/wallet.css" />
{/block}
{block name="pageType"}chongzhi{/block}
{block name="main" }
<div class="page-bd">
    <!-- 页面内容-->

    <div class="paytype">
            <div class="">
                <div class="title fs28 fw_b color_3">
                    <label class="weui-label" >支付金额：{$orderInfo.order_amount}</label>
                    <input type="hidden" id="order_amount" value="{$orderInfo.order_amount}">
                    <input type="hidden" id="order_id" value="{$orderInfo.order_id}">
                </div>
            </div>

        <div class="">
            <div class="title fs28 fw_b color_3">收款码</div>
            <div class="uploadBox">

                <div style="width: 190px;height: 190px;">
                    <img style="width: 100%" src="{$data["pay_config"]['qcode']}" alt="" class="imgBox">

                </div>
            </div>
        </div>
    </div>
    <div class="paytype">
        <div class="cells">


        </div>
        <div class="uploading">
            <div class="title fs28 fw_b color_3">上传凭证</div>
            <div class="uploadBox">

                <div class="Box">
                    <img src="__STATIC__/mobile/default/images/addImg.png" alt="" class="imgBox">
                    <input type="file" class="uploadInput" onchange="uploadFile(this,event)">
                    <input id="uploaderInput1" name="pay_img" class="weui-uploader__input imgs" type="hidden" accept="image/*" />

                </div>
            </div>
        </div>
    </div>

    <div class="button fs32 fw_b color_w BGcolor_r postBtn">确认</div>

</div>
</div>
{/block}
{block name="footer"}
<script type="text/javascript">
    $(function(){
        //加载支付列表中
        jq_ajax('{:url("publics/api.pay/getList",["type"=>"is_recharge"])}','',function(res){
            if (res.code==0){
                _alert(res.msg);
                return false;
            }
            $('.cells').html(template('payListTpl',res));
        });
        $('.textBox').on('click',function(){
            $(this).siblings().animate({'fontSize':'0.173333rem','top':'0.2666666rem'})
        })
        $('.inputBlock input').blur(function(){
            if($(this).val()==''){
                $(this).siblings().animate({'fontSize':'0.4rem','top':'0.386667rem'})
            }
        })
        $('.uploading').show()
    })

    var isPost = false
    var fd = new FormData();
    var imgNum = 0;
    $('.postBtn').click(function(){
        if (isPost == true) return false;
        var order_amount = $('#order_amount').val();
        var order_id = $('#order_id').val();
        var pay_img = $('#uploaderInput1').val();
        console.log(pay_img)
        var pay_code = 'offline';
        // if (order_amount < 1){
        //     _alert('充值金额不能少于1.');
        //     return false;
        // }
        fd.append("pay_code",pay_code);
        fd.append("order_amount", order_amount);
        isPost = true;
        // window.location.href = '{:_url("shop/payment/getCode2",["order_id"=>"【order_id】","pay_code"=>"offline","pay_img"=>"【pay_img】"])}';
        window.location.href = '{:_url("shop/payment/getCode2",["order_id"=>"【order_id】"])}?pay_code=offline&pay_img='+pay_img;
        // $.ajax({
        //     url: '{:url("shop/payment/getCode2")}',
        //     type: 'post',
        //     processData: false,
        //     contentType: false,
        //     data: fd,
        //     success: function (res) {
        //         isPost = false;
        //         if (res.code == 0){
        //             _alert(res.msg);
        //             return false;
        //         }
        //         if (pay_code ==  'offline'){
        //             _alert(res.msg,'{:url("member/wallet/index")}');
        //             return false;
        //         }
        //
        //     }
        // })


    })
    //删除上传图片

    //选择上传图片
    function uploadFile(_this,e){
        compress(e, function(base64Img){

            if (imgNum > 1){
                _alert('最多允许上传1张图片.');
                return false;
            }
            $(_this).parent().before('<div class="Box"><img src="'+base64Img+'" alt="" class="imgBox"></div>');
            console.log()
            $.ajax({
                url: '{:url("shop/Flow/upload_base64_paycode")}',
                type: 'post',
                dataType : 'json',
                data: {img:base64Img},
                success: function (data) {
                    console.log(data['data'])
                    if(data.status == 200){
                        window.return_img = data.data
                        $("#uploaderInput1").val(data.data)
                        $('.weui-uploader__input-box').addClass('remove');
                    }else {

                    }

                }
            })
        })

    }

</script>

{/block}